//
// Created by Asus on 2025/6/1.
//

#include <iostream>
#include <string>
using namespace std;

class Person {
public:
    Person(string name, int age) {
        this->m_Name = name;
        this->m_Age = age;
    };

    bool operator==(Person &p) {
        if (this->m_Name == p.m_Name && this->m_Age == p.m_Age) {
            return true;
        } else {
            return false;
        }
    }

    bool operator!=(Person &p) {
        if (this->m_Name == p.m_Name && this->m_Age == p.m_Age) {
            return false;
        } else {
            return true;
        }
    }

    string m_Name;
    int m_Age;
};

void test01() {
    //int a = 0;
    //int b = 0;

    Person a("孙悟空", 18);
    Person b("孙悟空", 18);

    if (a == b) {
        cout << "a和b相等" << endl;
    } else {
        cout << "a和b不相等" << endl;
    }

    if (a != b) {
        cout << "a和b不相等" << endl;
    } else {
        cout << "a和b相等" << endl;
    }
}

class MyPrint {
public:
    void operator()(string text) {
        cout << text << endl;
    }
};

void test02() {
    MyPrint myPrint;
    myPrint("MyPrint");
}

class MyAdd
{
public:
    int operator()(int v1, int v2)
    {
        return v1 + v2;
    }
};

void test03()
{
    MyAdd add;
    int ret = add(10, 10);
    cout << "ret = " << ret << endl;
    //匿名对象调用
    cout << "MyAdd()(100,100) = " << MyAdd()(100, 100) << endl;
}

int main(int argc, char *argv[]) {
    // test01();
    // test02();
    test03();
    return 0;
}
